﻿using System;

namespace Microsoft.Xna.Framework.Input
{
    /// <summary>
    /// Allows retrieval of user interaction with an Xbox 360 Controller and setting of controller vibration motors.
    /// </summary>
    public class GamePad
    {
        #region Public Methods
        /// <summary>
        /// Gets the current state of a game pad controller.
        /// </summary>
        /// <param name="playerIndex">Player index for the controller you want to query.</param>
        public static GamePadState GetState(PlayerIndex playerIndex)
        {
			return GetState(playerIndex, GamePadDeadZone.IndependentAxes);
        }

		/// <summary>
		/// Gets the current state of a game pad controller, using a specified dead zone on analog stick positions.
		/// </summary>
		/// <param name="playerIndex">Player index for the controller you want to query.</param>
		/// <param name="gamePadDeadZone">Enumerated value that specifies what dead zone type to use.</param>
		public static GamePadState GetState(PlayerIndex playerIndex, GamePadDeadZone gamePadDeadZone)
		{
			if (playerIndex != PlayerIndex.One)
				throw new InvalidOperationException("Only PlayerIndex.One is supported.");

			// like Windows Phone, only one Button (Buttons.Back) is mapped.
			// in this case, it is mapped to Keys.Escape
			if (Keyboard.GetState().IsKeyDown(Keys.Escape))
			{
				GamePadState state = new GamePadState(Vector2.Zero, Vector2.Zero, 0.0f, 0.0f, Buttons.Back);
				return state;
			}
			else
			{
				return new GamePadState();
			}
		}

        /// <summary>
        /// Sets the vibration motor speeds on an Xbox 360 Controller.
        /// </summary>
        /// <param name="index">Player index that identifies the controller to set.</param>
        /// <param name="leftMotor">The speed of the left motor, between 0.0 and 1.0. This motor is a low-frequency motor.</param>
        /// <param name="rightMotor">The speed of the right motor, between 0.0 and 1.0. This motor is a high-frequency motor.</param>
        public static bool SetVibration(PlayerIndex index, float leftMotor, float rightMotor)
        {
			return false;
        }
        #endregion
    }
}
